#!/usr/bin/python 

import pycurl
import re

def testa_autenticacao(url,nusp,senha):
	c = pycurl.Curl()
	c.setopt(pycurl.URL, url)
#c.setopt(pycurl.URL, "https://sistemas2.usp.br/jupiterweb/autenticar")
	c.setopt(pycurl.POST, 1)
	c.setopt(pycurl.POSTFIELDS, "codpes="+nusp+"&senusu="+senha+"&submit=Entrar")
#c.setopt(pycurl.POSTFIELDS, "codpes=5434577&senusu=123456&submit=Entrar")

	import StringIO
	b = StringIO.StringIO()
	c.setopt(pycurl.WRITEFUNCTION, b.write)
	c.perform()
#print b.getvalue()

	if re.search("Incorreta!", b.getvalue()):
		return "Erro"
	else:
		return "OK"

name = raw_input("Please enter your name:")

a = testa_autenticacao("https://sistemas2.usp.br/jupiterweb/autenticar",name,"123456")
a = a + "<br/>"
a = a + testa_autenticacao("https://sistemas2.usp.br/jupiterweb/autenticar","5434577","1234562")

print a
